package com.heer.gymnasium.module.order.beans;

import com.heer.gymnasium.base.BaseBean;
import com.heer.gymnasium.constant.Type;
import com.heer.gymnasium.util.StringUtils;
import com.zhihuiyun.library.commonadapter.QuickInterface;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by yan on 2018/1/23.
 * 我的订单列表中item bean
 */

public class MyOrderBean extends BaseBean {

    private String orderId;//订单id
    private String stadiumName;//店铺名称
    private String payStaus;//支付状态，1：已支付
    private String orderTime;//下订单时间
    private String cancelStatus;//	订单是否可取消，1：可取消
    private String payMoney;//支付金额
    private String orderNum;//订单中有几件商品
    private String orderType;//11:订场,21:购卡,31:充值,41：私教
    private String isAuto;//	1:自动续订
    private String orderStatus;//1,正常,2用户取消订单,3商家关闭订单,4未支付取消的
    private String cropsId;
    private List detailList;
    private boolean isOpen = false;
    private String isEval;//评价成员/评价战队
    private boolean isEvalStore;//评价店铺

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getStadiumName() {
        return stadiumName;
    }

    public void setStadiumName(String stadiumName) {
        this.stadiumName = stadiumName;
    }

    public String getPayStaus() {
        return payStaus;
    }

    public void setPayStaus(String payStaus) {
        this.payStaus = payStaus;
    }

    public String getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(String orderTime) {
        this.orderTime = orderTime;
    }

    public String getCancelStatus() {
        return cancelStatus;
    }

    public void setCancelStatus(String cancelStatus) {
        this.cancelStatus = cancelStatus;
    }

    public String getPayMoney() {
        return payMoney;
    }

    public void setPayMoney(String payMoney) {
        this.payMoney = payMoney;
    }

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }


    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public String getIsAuto() {
        return isAuto;
    }

    public void setIsAuto(String isAuto) {
        this.isAuto = isAuto;
    }

    public String getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }

    public String getCropsId() {
        return cropsId;
    }

    public void setCropsId(String cropsId) {
        this.cropsId = cropsId;
    }

    public List getDetailList() {
        return detailList;
    }

    public void setDetailList(List detailList) {
        this.detailList = detailList;
    }

    public boolean isOpen() {
        return isOpen;
    }

    public void setOpen(boolean open) {
        isOpen = open;
    }

    public String getIsEval() {
        return isEval;
    }

    public void setIsEval(String isEval) {
        this.isEval = isEval;
    }

    public boolean isEvalStore() {
        return isEvalStore;
    }

    public void setEvalStore(boolean evalStore) {
        isEvalStore = evalStore;
    }

    public static class DetialStadium extends CommonDetial implements QuickInterface {

        private String placeName;//场地名称
        private List<String> placeList;//卡所关联的场地列表
        private String time;//订场时间
        private String detailId;


        public String getPlaceName() {
            return placeName;
        }

        public void setPlaceName(String placeName) {
            this.placeName = placeName;
        }


        public List<String> getPlaceList() {
            return placeList;
        }

        public void setPlaceList(List<String> placeList) {
            this.placeList = placeList;
        }

        public String getTime() {
            return time;
        }

        public void setTime(String time) {
            this.time = time;
        }

        @Override
        public int getType() {
            return 0;
        }

        @Override
        public String getDetailId() {
            return detailId;
        }

        @Override
        public void setDetailId(String detailId) {
            this.detailId = detailId;
        }
    }

    public static class DetailCard extends CommonDetial implements QuickInterface {
        private String placename;
        private String cardType;
        private String cardName;

        public String getPlacename() {
            return placename;
        }

        public void setPlacename(String placename) {
            this.placename = placename;
        }

        public String getCardType() {
            return cardType;
        }

        public void setCardType(String cardType) {
            this.cardType = cardType;
        }

        public String getCardName() {
            return cardName;
        }

        public void setCardName(String cardName) {
            this.cardName = cardName;
        }

        @Override
        public int getType() {
            return 0;
        }
    }

    public static class DetailRecharge extends CommonDetial implements QuickInterface {

        private String giveMoney;

        public String getGiveMoney() {
            return giveMoney;
        }

        public void setGiveMoney(String giveMoney) {
            this.giveMoney = giveMoney;
        }

        @Override
        public int getType() {
            return 0;
        }
    }

    public static class DetailCoach extends CommonDetial implements QuickInterface {//私教详情

        private String coachName;

        public String getCoachName() {
            return coachName;
        }

        public void setCoachName(String coachName) {
            this.coachName = coachName;
        }


        @Override
        public int getType() {
            return 0;
        }
    }

    public static class CommonDetial {//
        private String detailId;
        private String price;
        private String cancelStatus;//取消状态
        private String isEval;//评价状态
        private String num;
        private String orderStatus;

        public String getDetailId() {
            return detailId;
        }

        public void setDetailId(String detailId) {
            this.detailId = detailId;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getCancelStatus() {
            return cancelStatus;
        }

        public void setCancelStatus(String cancelStatus) {
            this.cancelStatus = cancelStatus;
        }

        public String getIsEval() {
            return isEval;
        }

        public void setIsEval(String isEval) {
            this.isEval = isEval;
        }

        public String getNum() {
            return num;
        }

        public void setNum(String num) {
            this.num = num;
        }

        public String getOrderStatus() {
            return orderStatus;
        }

        public void setOrderStatus(String orderStatus) {
            this.orderStatus = orderStatus;
        }
    }

    //
    public static List<MyOrderBean> dataChange(List<OrderResponseListBean.Item> beanList) {
        List<MyOrderBean> myOrderBeanList = new ArrayList<>();
        if (beanList != null) {
            for (int i = 0; i < beanList.size(); i++) {
                OrderResponseListBean.Item item = beanList.get(i);
                MyOrderBean bean = new MyOrderBean();
                bean.setOrderId(item.getOrder_id());
                bean.setStadiumName(item.getStadium_name());
                bean.setPayStaus(item.getPay_status());
                bean.setOrderTime(StringUtils.getPhpDateFormat(item.getOrder_time(), new SimpleDateFormat("yyyy.MM.dd")));
                bean.setCancelStatus(item.getCancel_status());
                bean.setPayMoney(item.getPay_money());
                bean.setOrderNum(item.getOrder_num());
                bean.setOrderType(item.getOrderType());
                bean.setIsAuto(item.getIs_auto());
                bean.setOrderStatus(item.getStatus());
                bean.setCropsId(item.getCorps_id());
                if (item.getOrderType().equals(Type.STADIUM_YUE)) {
                    bean.setIsEval(item.getIs_eval_corps());
                }
                if (item.getOrderType().equals(Type.STADIUM_FELLOW)) {
                    bean.setIsEval(item.getIs_eval_user());
                }
                if (item.getIs_eval().equals("1")) {
                    bean.setEvalStore(true);
                } else {
                    bean.setEvalStore(false);
                }

                if (item.getOrderType().equals(Type.STADIUM_TYPE) || item.getOrderType().equals(Type.STADIUM_TICKET_TYPE)
                        || item.getOrderType().equals(Type.STADIUM_YUE) || item.getOrderType().equals(Type.STADIUM_FELLOW)) {
                    List<DetialStadium> stadiumList = new ArrayList<>();
                    List<OrderResponseListBean.OrderDetialResponseBean> list = item.getDetail_list();
                    for (int j = 0; j < list.size(); j++) {
                        DetialStadium detail = new DetialStadium();
                        OrderResponseListBean.OrderDetialResponseBean detailItem = list.get(j);
                        detail.setDetailId(detailItem.getDetail_id());
                        detail.setPlaceName(detailItem.getPlace_name());
                        detail.setPrice(detailItem.getPrice());
                        detail.setPlaceList(detailItem.getPlace_list());
                        detail.setTime(StringUtils.getPhpDateFormat(detailItem.getStime(), new SimpleDateFormat("yyyy-MM-dd HH:mm")) + "-"
                                + StringUtils.getPhpDateFormat(detailItem.getEtime(), new SimpleDateFormat("HH:mm")));
                        detail.setNum("1");
                        detail.setCancelStatus(detailItem.getCancel_status());
                        detail.setIsEval(detailItem.getIs_eval());
                        detail.setOrderStatus(detailItem.getStatus());
                        stadiumList.add(detail);
                    }
                    bean.setDetailList(stadiumList);

                } else if (item.getOrderType().equals(Type.BUY_CARD_TYPE)) {
                    List<DetailCard> cardList = new ArrayList<>();
                    List<OrderResponseListBean.OrderDetialResponseBean> list = item.getDetail_list();
                    for (int j = 0; j < list.size(); j++) {
                        DetailCard detail = new DetailCard();
                        OrderResponseListBean.OrderDetialResponseBean detailItem = list.get(j);
                        detail.setDetailId(detailItem.getDetail_id());
                        detail.setPlacename(detailItem.getPlace_name());
                        detail.setCardType(detailItem.getCat_name());
                        detail.setPrice(detailItem.getPrice());
                        detail.setCancelStatus(detailItem.getCancel_status());
                        detail.setIsEval(detailItem.getIs_eval());
                        detail.setOrderStatus(detailItem.getStatus());
                        detail.setNum("1");
                        cardList.add(detail);
                    }
                    bean.setDetailList(cardList);
                } else if (item.getOrderType().equals(Type.RECHARGE_TYPE)) {
                    List<DetailRecharge> rechargeList = new ArrayList<>();
                    List<OrderResponseListBean.OrderDetialResponseBean> list = item.getDetail_list();
                    for (int j = 0; j < list.size(); j++) {
                        DetailRecharge detail = new DetailRecharge();
                        OrderResponseListBean.OrderDetialResponseBean detailItem = list.get(j);
                        detail.setDetailId(detailItem.getDetail_id());
                        detail.setPrice(detailItem.getPrice());
                        detail.setGiveMoney(detailItem.getGive_price());
                        detail.setCancelStatus(detailItem.getCancel_status());
                        detail.setIsEval(detailItem.getIs_eval());
                        detail.setOrderStatus(detailItem.getStatus());
                        detail.setNum("1");
                        rechargeList.add(detail);
                    }
                    bean.setDetailList(rechargeList);
                } else if (item.getOrderType().equals(Type.COACH_TYPE)) {
                    List<DetailCoach> detialList = new ArrayList<>();
                    List<OrderResponseListBean.OrderDetialResponseBean> list = item.getDetail_list();
                    for (int j = 0; j < list.size(); j++) {
                        DetailCoach detail = new DetailCoach();
                        OrderResponseListBean.OrderDetialResponseBean detailItem = list.get(j);
                        detail.setDetailId(detailItem.getDetail_id());
                        detail.setPrice(detailItem.getPrice());
                        detail.setCoachName(detailItem.getCoach_name());
                        detail.setNum(detailItem.getBuy_num());
                        detail.setCancelStatus(detailItem.getCancel_status());
                        detail.setIsEval(detailItem.getIs_eval());
                        detail.setOrderStatus(detailItem.getStatus());
                        detialList.add(detail);
                        bean.setOrderNum(detailItem.getBuy_num());

                    }
                    bean.setDetailList(detialList);
                }
                myOrderBeanList.add(bean);
            }
        }
        return myOrderBeanList;
    }
}
